from django.db import models
import datetime

class Poll(models.Model):
    question = models.CharField(max_length = 128)
    created_at = models.DateTimeField('created time')
    
    def was_published_today(self):
        return datetime.datetime.now() == self.created_at
    was_published_today.short_description = "Published today?"
    
    def __unicode__(self):
        return self.question

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    name = models.CharField(max_length = 128)
    votes = models.IntegerField()
    
    def __unicode__(self):
        return self.name
